<template>
  <var-app-bar fixed round color="#f3edf7">
    <template #right>
      <var-space>
        <var-icon name="bell" color="#6750a4" :size="24" />
        <var-icon
          @click="router.push('/settings')"
          name="cog-outline"
          color="#6750a4"
          :size="24"
        />
      </var-space>
    </template>

    <template #content>
      <div class="info">
        <var-image
          width="65px"
          height="65px"
          fit="cover"
          radius="50%"
          :src="info?.avatar"
        />
        <div class="right">
          <span>{{ info?.username }}</span>
          <span>{{ info?.area }}</span>
        </div>
      </div>

      <var-tabs color="transparent" v-model:active="infoStore.myActive">
        <var-tab name="dynamic">我的动态</var-tab>
        <var-tab name="star">赞过</var-tab>
        <var-tab name="collect">收藏</var-tab>
      </var-tabs>
    </template>
  </var-app-bar>
  <div class="view" v-if="infoStore.userInfo">
    <router-view />
  </div>
</template>

<script setup lang="ts">
import { useInfoStore } from '@/store/info'

const router = useRouter()

const infoStore = useInfoStore()
const info = ref(null)
info.value = JSON.parse(JSON.stringify(infoStore.userInfo))

watch(
  () => infoStore.myActive,
  val => {
    router.push(`/my/${val}`)
  }
)
</script>

<style scoped lang="scss">
.info {
  padding: 10px;
  display: flex;
  .right {
    margin-left: 10px;
    font-size: 18px;
    color: #6750a4;
    display: flex;
    flex-direction: column;
    justify-content: end;
    gap: 5px;
    span {
      &:first-child {
        font-weight: bold;
        font-size: 18px;
      }

      &:last-child {
        font-size: 14px;
      }
    }
  }
}

.view {
  padding-top: 130px;
}
</style>
